<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //利用所学函数知识求解 1!+2!+3!+....+n!，其中n！用递归调用实现
        // function getSum(num){
        //     var sum = 0;
        //     for(var i = 1; i <= num; i++){
        //         var ret = 1;
        //         for(var j = 1; j <= i; j++){
        //             ret *= j;
        //         }
        //         sum += ret;
        //     }
        //     return sum;
        // }
        function getSum(num){
            var sum = 0;
            var ret = 1;
            for(var i = 1; i <= num; i++){
                ret *= i;
                sum += ret;
            }
            return sum;
        }
    
        var num = prompt('请输入你所要求的n的阶乘：');
        var sum = getSum(num);
        alert(sum);
    </script>
</head>
<body>
    
</body>
</html>